# -*- coding: utf-8 -*-
import os

def findfile(key,inputdir='.'):
    found_list = []
    for path,dirnames,filenames in os.walk(inputdir):
        print('searching',path,'...')
        for name in filenames:
            full_name = path + '/' + name
            if key in name:
                found_list.append(full_name)
            with open(full_name,encoding ='UTF-8',errors='ignore')as f:

                for l in f.readlines():
                    if key in l:
                        found_list.append(full_name + ':' + l)
        return found_list


keyword = input('search:')
path = input('in:')
if not path.strip():
    path='.'
result = findfile(keyword,path)

print('\n=======result========\n\n')
for r in result:
    print(r)
